import {
  AddContentDirParams,
  ContentDirList,
  ContentDirListParams,
  CopyContentDirParams,
  EditContentDirParams,
  PublishContentDirParams,
} from '@/types/contentMng/contentDirectory';
import { ResponseResult } from '@/types/type';
import request from '@/utils/request';

/**
 * @description 查询目录内容列表
 * @param params
 * @returns
 */
export async function contentDirList(params: ContentDirListParams) {
  return request.get<{
    statusCode: string;
    statusMessage: string;
    data: ContentDirList;
  }>('/content/directory/find', {
    params,
  });
}

/**
 * @description 添加目录
 * @param params
 * @returns
 */
export async function addContentDir(data: AddContentDirParams) {
  return request.post('/content/directory/add', {
    data,
  });
}

/**
 * @description 编辑目录
 * @param params
 * @returns
 */
export async function editContentDir(data: EditContentDirParams) {
  return request.put('/content/directory/edit', {
    data,
  });
}

/**
 * @description 目录发布、目录取消发布
 * @param params
 * @returns
 */
export async function publishContentDir(data: PublishContentDirParams) {
  return request.post('/content/directory/publish', {
    data,
  });
}

/**
 * @description 删除目录
 * @param params 目录sid
 * @returns
 */
export async function deleteContentDir(params: { sid: string }) {
  return request.put('/content/directory/delete', {
    params,
  });
}

/**
 * @description 对已发布目录进行排序
 * @param params sid:目录sid, orderNo:序号
 * @returns
 */

export async function sortContentDir(data: { sid: string; orderNo: string }) {
  return request.post('/content/directory/sort', {
    data,
  });
}

/**
 * @description 复制目录到模板下
 * @param params
 * @returns
 */

export async function copyContentDir(data: CopyContentDirParams) {
  return request.post('/content/directory/copy', {
    data,
  });
}
